package com.fcgzs.springboot.controller;


import com.fcgzs.springboot.pojo.Ordersetting;
import com.fcgzs.springboot.service.OrdersettingService;
import com.fcgzs.springboot.util.POIUtils;
import com.fcgzs.springboot.util.Result;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wjd
 * @since 2021-10-12
 */
@RestController
@RequestMapping("/ordersetting")
public class OrdersettingController {

    @Reference
    private OrdersettingService ordersettingService;
    //上传模板
    @RequestMapping("/uploadTemplate")
    public Result uploadTemplate(MultipartFile excelFile){
        Result result = null;
        //List中存放 [年-月-日，可预约人数]
        try {
            List<String[]> strings = POIUtils.readExcel(excelFile);
            result = ordersettingService.saveOrdersettingInfo(strings);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }
    //展示预约信息
    @RequestMapping("/showOrdersetting")
    public Result showOrdersetting(String date){
        return ordersettingService.showOrdersetting(date);
    }
    //修改预约信息
    @RequestMapping("/updateNumber")
    public Result updateNumber(@RequestBody Ordersetting ordersetting){
        return ordersettingService.updateNumber(ordersetting);
    }

}

